#ifdef _SCYTHEPLUGIN
#include "..\ode plugin\general.h"
#else
#include "Scythe.h"
#endif

namespace Scythe {
/*
void stringToLower(std::string &s)
{
//	char* c = new char[s.size()];
	int i;
	for (i = 0; i < (int)s.size(); i++)
	{
//		c[i] = s[i];
		s[i] = tolower(s[i]);
//		s[i] = c[i];
	}
//	delete c;
}


/*
==========================
mat4 functions, used only in utility.cpp
==========================
*/

void mat4Ident(float* m)
{
	m[0] = 1;
	m[1] = 0;
	m[2] = 0;
	m[3] = 0;
	m[4] = 0;
	m[5] = 1;
	m[6] = 0;
	m[7] = 0;
	m[8] = 0;
	m[9] = 0;
	m[10] = 1;
	m[11] = 0;
	m[12] = 0;
	m[13] = 0;
	m[14] = 0;
	m[15] = 1;
}
void mat34Ident(float* m)
{
	m[0] = 1;
	m[1] = 0;
	m[2] = 0;
	m[3] = 0;
	m[4] = 0;
	m[5] = 1;
	m[6] = 0;
	m[7] = 0;
	m[8] = 0;
	m[9] = 0;
	m[10] = 1;
	m[11] = 0;
}

void mat4_Mult(const mat4_t a, const mat4_t b, mat4_t &product)
{
	int i;
	float a0, a1, a2, a3;
	mat4_t p;

	for (i=0; i<4; i++)
	{
		a0 = a[i];
		a1 = a[4+i];
		a2 = a[8+i];
		a3 = a[12+i];
		p[i]    = a0*b[0]  + a1*b[1]  + a2*b[2]  + a3*b[3];
		p[4+i]  = a0*b[4]  + a1*b[5]  + a2*b[6]  + a3*b[7];
		p[8+i]  = a0*b[8]  + a1*b[9]  + a2*b[10] + a3*b[11];
		p[12+i] = a0*b[12] + a1*b[13] + a2*b[14] + a3*b[15];
	}

	// copy the result to the return value
	for(int i=0; i<16; i++)
		product[i] = p[i];
}


void nx33ToMat4(float* matrix_out, const Mat33 src)
{
	matrix_out[0] = src.m[0][0];
	matrix_out[1] = src.m[1][0];
	matrix_out[2] = src.m[2][0];

	matrix_out[4] = src.m[0][1];
	matrix_out[5] = src.m[1][1];
	matrix_out[6] = src.m[2][1];

	matrix_out[8] = src.m[0][2];
	matrix_out[9] = src.m[1][2];
	matrix_out[10] = src.m[2][2];
	
}
void nx33ToMat4nt(float* matrix_out, const Mat33 src)
{
	matrix_out[0] = src.m[0][0];
	matrix_out[1] = src.m[0][1];
	matrix_out[2] = src.m[0][2];

	matrix_out[4] = src.m[1][0];
	matrix_out[5] = src.m[1][1];
	matrix_out[6] = src.m[1][2];

	matrix_out[8] = src.m[2][0];
	matrix_out[9] = src.m[2][1];
	matrix_out[10] = src.m[2][2];
	/**/
}

void mat4ToNx33(const float* m, Mat33 &src)
{
	src.m[0][0] = m[0];
	src.m[1][0] = m[1];
	src.m[2][0] = m[2];

	src.m[0][1] = m[4];
	src.m[1][1] = m[5];
	src.m[2][1] = m[6];

	src.m[0][2] = m[8];
	src.m[1][2] = m[9];
	src.m[2][2] = m[10];
	
}
void mat4ToNx33nt(const float* m, Mat33 &src) {
	src.m[0][0] = m[0];
	src.m[0][1] = m[1];
	src.m[0][2] = m[2];
	src.m[1][0] = m[4];
	src.m[1][1] = m[5];
	src.m[1][2] = m[6];
	src.m[2][0] = m[8];
	src.m[2][1] = m[9];
	src.m[2][2] = m[10];
}

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////


}